//
//  YWFinishKeepWatchMissionCell.m
//  maintain
//
//  Created by 郑想 on 16/7/25.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWFinishKeepWatchMissionCell.h"
#import "YWAnimationView.h"
#import "UIView+Extension.h"
#import "UIColor+CustomColors.h"
#import "UIImageView+WebCache.h"
#import "Masonry.h"
//#import "UILabel+AttributedText.h"
#import "YWMacro.h"
#import "YWCommonTool.h"
#import "YYLabel.h"

#import "YWKeepWatchMission.h"
#import "YWPatrolLineRecord.h"
#import "YWKeepWatchMissionManager.h"

#import "YWBuilding.h"
#import "YWBuildingManager.h"

#import "YWContactManager.h"
#import "YWReplyManager.h"
#import "YWReply.h"

@interface YWFinishKeepWatchMissionCell()
//头像
@property (nonatomic, strong) UIImageView *headImageView;
//名字
@property (nonatomic, strong) YYLabel *nameLable;
//发布时间
@property (nonatomic, strong) YYLabel *releaseTimeLabel;
/** 记录状态 */
@property (nonatomic, strong) YYLabel *resultLabel;
/** 编号 */
@property (nonatomic, strong) YYLabel *numberLabel;
//巡更人
@property (nonatomic, strong) YYLabel *keepWatchPeopleleLable;
//位置名
@property (nonatomic, strong) YYLabel *keepWatchPlaceLable;
//路线
@property (nonatomic, strong) YYLabel *keepWatchLineLable;
//巡更时间
@property (nonatomic, strong) YYLabel *keepWatchTimeSlotLabel;
/** 巡更点总数 */
@property (nonatomic, strong) YYLabel *keepWatchEquimentAll;
/** 本次已完成 */
@property (nonatomic, strong) YYLabel *thisTimeHadFinishLabel;

@end

@implementation YWFinishKeepWatchMissionCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    YWFinishKeepWatchMissionCell *cell = [tableView dequeueReusableCellWithIdentifier:YWFinishKeepWatchMissionCellIdentifier];
    if (cell == nil) {
        cell = [[YWFinishKeepWatchMissionCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:YWFinishKeepWatchMissionCellIdentifier];
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.layer.shouldRasterize = YES;
        self.layer.rasterizationScale = [UIScreen mainScreen].scale;
        [self setUpSubviews];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        //self.separatorInset = UIEdgeInsetsMake(0, SCREEN_WIDTH, 0, 0);
    }
    return self;
}

-(void)setKeepWatchMission:(YWKeepWatchMission *)keepWatchMission{
    _keepWatchMission = keepWatchMission;
    YWBuilding* buliding = nil;
    if (keepWatchMission.buildingId.length) {
        buliding = [[YWBuildingManager shareManager] buildingWithId:keepWatchMission.buildingId];
    }else{
        YWPatrolLineLocationRel *locationRel = keepWatchMission.patrolLine.locationRels.count>0?keepWatchMission.patrolLine.locationRels[0]:nil;
        buliding = [[YWBuildingManager shareManager] buildingWithLocationId:locationRel.locationId];
    }
    //楼盘名
    //[_keepWatchPlaceLable labelText:@"位置: " withAttributedText:buliding.buildingName.length>0?buliding.buildingName:@"无" andAttributedColor:[UIColor blackColor]];
    NSString *locationText = buliding.buildingName.length>0?buliding.buildingName:NSLocalizedString(@"none", nil);
    _keepWatchPlaceLable.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"locationFormatter", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:locationText secondColor:[UIColor blackColor] font:kContentFont];
    
    //制定时间
    _releaseTimeLabel.text = [YWCommonTool showTimeWithNormalFormatter:_keepWatchMission.createTime / 1000];
    //    头像
    NSString* downloadUrl = [YWCommonTool pictureDownloadUrl:_keepWatchMission.creator.headIcon];
    [_headImageView sd_setImageWithURL:[NSURL URLWithString:downloadUrl] placeholderImage:[UIImage imageNamed:@"profile_headimage"]];
    //    制定人
    _nameLable.text = _keepWatchMission.creator.userName?:@"";
    //编号
    //[_numberLabel labelText:@"编号: " withAttributedText:_keepWatchMission.missionSequence.length>0?_keepWatchMission.missionSequence:@"无" andAttributedColor:[UIColor customYellowColor]];
    NSString *numberText = _keepWatchMission.missionSequence.length>0?_keepWatchMission.missionSequence:NSLocalizedString(@"none", nil);
    _numberLabel.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"codeFormatter", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:numberText secondColor:[UIColor customYellowColor] font:kContentFont];
    
    //路线名
    //[_keepWatchRouteLable labelText:@"巡更路线: " withAttributedText:keepWatchMission.patrolLine.patrolLineName?keepWatchMission.patrolLine.patrolLineName:@"无" andAttributedColor:[UIColor blackColor]];
    NSString *lineName = keepWatchMission.patrolLine.patrolLineName?keepWatchMission.patrolLine.patrolLineName:NSLocalizedString(@"none", nil);
    _keepWatchLineLable.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"keepWatchLine", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:lineName secondColor:[UIColor blackColor] font:kContentFont];
    
    //巡更人
    //[_keepWatchPeopleleLable labelText:@"巡更人: " withAttributedText:[YWCommonTool handlerNamesWithHandlers:keepWatchMission.executors]?:@"" andAttributedColor:[UIColor customYellowColor]];
    NSString *handlerText = [YWCommonTool handlerNamesWithHandlers:keepWatchMission.executors]?:@"";
    _keepWatchPeopleleLable.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"keepWatchExecutor", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:handlerText secondColor:[UIColor customYellowColor] font:kContentFont];
    
    //    巡差时间段
    NSArray *looperTimeArray = [YWCommonTool looperTimeArrayWithMission:keepWatchMission];
    NSTimeInterval lineRecordStarTime = (looperTimeArray.count>0?[[looperTimeArray firstObject] longLongValue]:0);
    NSTimeInterval lineRecordEndTime = (looperTimeArray.count>0?[[looperTimeArray lastObject] longLongValue]:0);
    NSString *startTime = nil;
    NSString *endTime = nil;
    if (keepWatchMission.patrolLine.intervalMinute>24*60) {
        startTime = [YWCommonTool showTime:lineRecordStarTime andFormatter:KTimeFormatShortDate];
        endTime = [YWCommonTool showTime:lineRecordEndTime andFormatter:KTimeFormatShortDate];
    }else{
        startTime = [YWCommonTool showTime:lineRecordStarTime andFormatter:KTimeFormatShortTime];
        endTime = [YWCommonTool showTime:lineRecordEndTime andFormatter:KTimeFormatShortTime];
    }
    NSString *timeString = (lineRecordStarTime==0 && lineRecordEndTime==0) ? NSLocalizedString(@"notWorkTime", nil) :[NSString stringWithFormat:@"%@-%@",startTime,endTime];
    //[_keepWatchTimeSlotLabel labelText:@"巡更时间: " withAttributedText:timeString andAttributedColor:[UIColor customYellowColor]];
    _keepWatchTimeSlotLabel.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"keepWatchTime", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:timeString secondColor:[UIColor customYellowColor] font:kContentFont];
    
    if ([YWCommonTool containSelfInHandlers:_keepWatchMission.executors]) {
        //    一共有巡更点
        //[_keepWatchEquimentAll labelText:@"巡更点总数: " withAttributedText:[NSString stringWithFormat:@"%lu个",(unsigned long)_keepWatchMission.patrolLine.locationRels.count] andAttributedColor:[UIColor customYellowColor]];
        NSString * allCountText = [NSString stringWithFormat:@"%lu个",(unsigned long)_keepWatchMission.patrolLine.locationRels.count];
        _keepWatchEquimentAll.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"keepWatchCount", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:allCountText secondColor:[UIColor customYellowColor] font:kContentFont];
        
        //    完成点
        NSString *uniqueTag = [YWCommonTool uniqueTagWithMission:_keepWatchMission];
        NSInteger count = [[YWKeepWatchMissionManager shareManager] countOfPatrolPointRecordWithUniqueTag:uniqueTag];
        //[_thisTimeHadFinishLabel labelText:@"已完成: " withAttributedText:[NSString stringWithFormat:@"%lu个",(unsigned long)count] andAttributedColor:[UIColor customYellowColor]];
        NSString *finishText = [NSString stringWithFormat:@"%lu个",(unsigned long)count];
        _thisTimeHadFinishLabel.attributedText = [YWCommonTool attributedTextWithFirstText:@"已完成: " firstColor:[UIColor customTextGrayBlackColor] secondText:finishText secondColor:[UIColor customYellowColor] font:kContentFont];
    }else{
        _keepWatchEquimentAll.text = @"";
        _thisTimeHadFinishLabel.text = @"";
    }
    //任务参与人
    NSMutableArray *tempArray = [NSMutableArray array];
    NSMutableArray *observerArray = [NSMutableArray array];
    [tempArray addObject:_keepWatchMission.creator];
    [tempArray addObjectsFromArray:_keepWatchMission.executors];
    [tempArray addObjectsFromArray:_keepWatchMission.observers];
    for (YWHandler *handler in tempArray) {
        NSInteger uniqueId = handler.uniqueId;
        NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"%K = %ld", @"uniqueId", uniqueId];
        NSArray *array = [[observerArray filteredArrayUsingPredicate:searchPredicate] mutableCopy];
        if (array.count==0) {
            [observerArray addObject:handler];
        }
    }
    NSString * firstStr = [NSString stringWithFormat:@"参与人(%ld): ",(long)observerArray.count];
    NSMutableString *observerName = [[NSMutableString alloc] init];
    [observerArray enumerateObjectsUsingBlock:^(YWHandler*  _Nonnull handler, NSUInteger idx, BOOL * _Nonnull stop) {
        if (observerName.length && idx!=0) {
            [observerName appendString:@" "];
        }
        [observerName appendString:handler.userName];
    }];
    
    NSString * nameStr = [NSString stringWithFormat:@"%@",observerName?:@""];//参与者要加进来
    
    self.observersLabel.attributedText = [YWCommonTool attributedTextWithFirstText:firstStr firstColor:[UIColor customTextGrayBlackColor] secondText:nameStr secondColor:[UIColor customBlueColor] font:kContentFont];
    //有评论
    NSArray *commentArray = [[YWReplyManager alloc] replysWithtRelationId:_keepWatchMission.keepWatchMissionId andRelationType:YWReplyRelationTypeKeepWatch];
    if (commentArray.count>0) {
        YWReply * reply = [commentArray firstObject];
        NSString * replyCount = [NSString stringWithFormat:@"评论(%ld): ",commentArray.count];
        //    时间
        NSString * timeStr = [YWCommonTool recordDateByFormatTimeString:reply.replyTime/1000 showYear:YES];
        //    内容
        
        NSString *atUserName = reply.atUser.userName.length>0?[NSString stringWithFormat:@" @%@",reply.atUser.userName]:@"";
        NSString * content = atUserName.length?[NSString stringWithFormat:@" %@  ",reply.content.length>0?reply.content:@""] : (reply.content.length>0?reply.content:@"");
        
        self.replyLabel.attributedText = [YWCommonTool attributedTextWithFirstText:replyCount firstColor:[UIColor customTextGrayColor] firstFont:kContentFont secondText:reply.replier.userName secondColor:[UIColor customBlueColor] secFont:kContentFont thirdText:atUserName thirdColor:[UIColor customBlueColor] thirdFont:kContentFont fourthText:content fourthColor:[UIColor blackColor] fourFont:kContentFont fifthText:timeStr fifthColor:[UIColor customTextGrayColor] fifthFont:[UIFont systemFontOfSize:13]];
    }else{
        self.replyLabel.attributedText = nil;
    }
    
    self.keepWatchPeopleleLable.preferredMaxLayoutWidth = self.keepWatchPeopleleLable.frame.size.width;
    self.keepWatchPlaceLable.preferredMaxLayoutWidth = self.keepWatchPlaceLable.frame.size.width;
    self.keepWatchLineLable.preferredMaxLayoutWidth = self.keepWatchLineLable.frame.size.width;
}

- (void)setLineRecord:(YWPatrollineRecord *)lineRecord{
    _lineRecord = lineRecord;
    YWBuilding *building = nil;
    if (lineRecord.keepWatchMission.buildingId.length) {
        building = [[YWBuildingManager shareManager] buildingWithId:lineRecord.keepWatchMission.buildingId];
    }else if (lineRecord.patrolLine.locationRels.count){
        YWPatrolLineLocationRel *locationRel = lineRecord.patrolLine.locationRels[0];
        building = [[YWBuildingManager shareManager] buildingWithLocationId:locationRel.locationId];
    }else{
        NSArray *finishPointRecords = [[YWKeepWatchMissionManager shareManager] patrolPointRecordWithUniqueTag:lineRecord.uniqueTag];
        if (finishPointRecords.count) {
            YWPatrolPointRecord *record = finishPointRecords.count?finishPointRecords[0]:nil;
            building = [[YWBuildingManager shareManager] buildingWithLocationId:record.locationId];
        }else{
            NSArray *patrolLocations = [[YWKeepWatchMissionManager shareManager] allPatrolLocationWithPatrolLineId:lineRecord.patrolLineId];
            YWPatrolLineLocationRel *patrolLocation = patrolLocations.count? patrolLocations[0]:nil;
            building = [[YWBuildingManager shareManager] buildingWithLocationId:patrolLocation.locationId];
        }
    }
    //楼盘名
    //[_keepWatchPlaceLable labelText:@"位置: " withAttributedText:building.buildingName.length>0?building.buildingName:@"无" andAttributedColor:[UIColor blackColor]];
    NSString *locationText = building.buildingName.length>0?building.buildingName:NSLocalizedString(@"none", nil);
    _keepWatchPlaceLable.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"locationFormatter", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:locationText secondColor:[UIColor blackColor] font:kContentFont];
    
    //制定时间
    _releaseTimeLabel.text = [YWCommonTool showTimeWithNormalFormatter:lineRecord.endTime / 1000];
    NSString *result = @"";
    if (lineRecord.result==YWPatrollineRecordResultUnfinishAndNormal){
        result = NSLocalizedString(@"unFinished", nil);
        self.resultLabel.textColor = [UIColor customRedColor];
    }else if (lineRecord.result==YWPatrollineRecordResultUnfinishAndTrouble) {
        result = NSLocalizedString(@"unFinishedAndTrouble", nil);//@"未完成(有报障)";
        self.resultLabel.textColor = [UIColor customRedColor];
    }else if (lineRecord.result==YWPatrollineRecordResultFinishAndTrouble){
        result = NSLocalizedString(@"hasFinishedAndTrouble", nil);//@"已完成(有报障)";
        self.resultLabel.textColor = [UIColor customRedColor];
    }else if (lineRecord.result==YWPatrollineRecordResultFinishAndNormal) {
        result = NSLocalizedString(@"hasFinished", nil);//@"已完成";
        self.resultLabel.textColor = [UIColor customTextGrayColor];
    }else if (lineRecord.result==YWPatrollineRecordResultSystem) {
        result = NSLocalizedString(@"noManToKeepWatch", nil);//@"无人巡更";
        self.resultLabel.textColor = [UIColor customTextGrayColor];
    }else{
        result = @"";
        self.resultLabel.textColor = [UIColor customTextGrayColor];
    }
    self.resultLabel.text = result;
    
    //    头像
    NSString* downloadUrl = nil;
    if (lineRecord.executors.count==1) {
        YWHandler *handler = lineRecord.executors[0];
        downloadUrl = [YWCommonTool pictureDownloadUrl:handler.headIcon];
        [_headImageView sd_setImageWithURL:[NSURL URLWithString:downloadUrl] placeholderImage:[UIImage imageNamed:@"profile_headimage"]];
    }else{
        _headImageView.image = [UIImage imageNamed:@"profile_headimage"];
    }
    
    //执行人
    _nameLable.text = lineRecord.result == YWPatrollineRecordResultSystem ? NSLocalizedString(@"noManToKeepWatch", nil) : ([YWCommonTool handlerNamesWithHandlers:lineRecord.executors]?:@"无");
    //编号
    //[_numberLabel labelText:@"编号: " withAttributedText:lineRecord.keepWatchMission.missionSequence.length>0?lineRecord.keepWatchMission.missionSequence:@"无" andAttributedColor:[UIColor customYellowColor]];
    NSString *numberText = lineRecord.keepWatchMission.missionSequence.length>0?lineRecord.keepWatchMission.missionSequence:NSLocalizedString(@"none", nil);
    _numberLabel.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"codeFormatter", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:numberText secondColor:[UIColor customYellowColor] font:kContentFont];
    
    //路线名
    NSString *lineName = lineRecord.patrolLine.patrolLineId==0?NSLocalizedString(@"tempKeepWatch", nil) : (lineRecord.patrolLine.patrolLineName?lineRecord.patrolLine.patrolLineName:NSLocalizedString(@"none", ni));
    //[_keepWatchLineLable labelText:@"巡更路线: " withAttributedText:lineName andAttributedColor:[UIColor blackColor]];
    _keepWatchLineLable.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"keepWatchLine", ni) firstColor:[UIColor customTextGrayBlackColor] secondText:lineName secondColor:[UIColor blackColor] font:kContentFont];
    
    //任务创建人
    //[_keepWatchPeopleleLable labelText:@"创建人: " withAttributedText:lineRecord.keepWatchMission.creator.userName?:@"无" andAttributedColor:[UIColor customYellowColor]];
    NSString *creatorText = lineRecord.keepWatchMission.creator.userName?:NSLocalizedString(@"none", ni);
    _keepWatchPeopleleLable.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"creatorFormatter", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:creatorText secondColor:[UIColor customYellowColor] font:kContentFont];
    
    NSString *startTime = nil;
    NSString *endTime = nil;
    if (lineRecord.patrolLine.intervalMinute>24*60) {
        startTime = [YWCommonTool showTime:lineRecord.startTime/1000 andFormatter:KTimeFormatShortDate];
        endTime = [YWCommonTool showTime:lineRecord.endTime/1000 andFormatter:KTimeFormatShortDate];
    }else{
        startTime = [YWCommonTool showTime:lineRecord.startTime/1000 andFormatter:KTimeFormatShortTime];
        endTime = [YWCommonTool showTime:lineRecord.endTime/1000 andFormatter:KTimeFormatShortTime];
    }
    NSString *timeString = [NSString stringWithFormat:@"%@-%@",startTime,endTime];
    //[_keepWatchTimeSlotLabel labelText:@"巡更时间: " withAttributedText:timeString andAttributedColor:[UIColor customYellowColor]];
    _keepWatchTimeSlotLabel.attributedText = [YWCommonTool attributedTextWithFirstText:NSLocalizedString(@"keepWatchTime", nil) firstColor:[UIColor customTextGrayBlackColor] secondText:timeString secondColor:[UIColor customYellowColor] font:kContentFont];
    
    //NSInteger count = lineRecord.patrolLine ? lineRecord.patrolLine.locationRels.count : 1;
    //[_keepWatchEquimentAll labelText:@"巡更点总数: " withAttributedText:[NSString stringWithFormat:@"%lu个",(unsigned long)count] andAttributedColor:[UIColor customYellowColor]];
    _keepWatchEquimentAll.text = @"";
    //    完成点
    _thisTimeHadFinishLabel.text = @"";
    
    
    self.keepWatchPeopleleLable.preferredMaxLayoutWidth = self.keepWatchPeopleleLable.frame.size.width;
    self.keepWatchPlaceLable.preferredMaxLayoutWidth = self.keepWatchPlaceLable.frame.size.width;
    self.keepWatchLineLable.preferredMaxLayoutWidth = self.keepWatchLineLable.frame.size.width;
}

- (void)setUpSubviews{
    UIView *superview = self.contentView;
    
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.mas_equalTo(superview).offset(8);
        make.width.and.height.mas_equalTo(@46);
    }];
    
    [self.nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(_headImageView.mas_centerY).offset(-2);
        make.left.mas_equalTo(_headImageView.mas_right).offset(6);
        make.right.lessThanOrEqualTo(superview.mas_right).offset(-110);
    }];
    
    [self.releaseTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_nameLable);
        make.top.mas_equalTo(_nameLable.mas_bottom).offset(4);
    }];
    [self.resultLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.baseline.mas_equalTo(_nameLable);
        make.right.mas_equalTo(superview).offset(-8);
    }];
    
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_headImageView.mas_bottom).offset(6);
        make.left.mas_equalTo(superview).offset(8);
        make.right.mas_equalTo(superview).offset(-8);
    }];
    
    [self.keepWatchPeopleleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_numberLabel.mas_bottom).offset(6);
    }];
    
    [self.keepWatchPlaceLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_keepWatchPeopleleLable.mas_bottom).offset(6);
        
    }];
    
    [self.keepWatchLineLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_keepWatchPlaceLable.mas_bottom).offset(6);
    }];
    [self.keepWatchTimeSlotLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_keepWatchLineLable.mas_bottom).offset(6);
    }];
    /**
     *  巡更点总数   已完成
     */
    [self.keepWatchEquimentAll mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_keepWatchTimeSlotLabel.mas_bottom).offset(6);
        make.left.and.right.mas_equalTo(@[_numberLabel,_keepWatchPeopleleLable,_keepWatchPlaceLable,_keepWatchLineLable,_keepWatchTimeSlotLabel]);
//        make.bottom.mas_equalTo(superview.mas_bottom).offset(-6);
    }];
    
    [self.separatorLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_keepWatchTimeSlotLabel.mas_bottom).offset(6);
        make.left.and.right.mas_equalTo(superview);
        make.height.mas_equalTo(@1.0);
    }];
    
    [self.observersLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.separatorLineView.mas_bottom).offset(6);
        make.left.and.right.mas_equalTo(_numberLabel);
    }];
    [self.replyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.observersLabel.mas_bottom).offset(6);
        make.left.and.right.mas_equalTo(_numberLabel);
        make.bottom.mas_equalTo(superview).offset(-6);
    }];

    [self.thisTimeHadFinishLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.baseline.mas_equalTo(_keepWatchEquimentAll);
        make.left.mas_equalTo(superview.centerX);
    }];
}

//- (void)layoutSubviews{
//    [super layoutSubviews];
//    
//}

- (UIImageView *)headImageView{
    if (!_headImageView) {
        UIImageView *imageView = [UIImageView new];
        imageView.layer.masksToBounds = YES;
        imageView.layer.cornerRadius = 46/2;
        
        _headImageView = imageView;
        [self.contentView addSubview:_headImageView];
    }
    return _headImageView;
}

- (YYLabel *)nameLable{
    if (!_nameLable) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.textColor = [UIColor blackColor];
        _nameLable = label;
        [self.contentView addSubview:_nameLable];
    }
    return _nameLable;
}

- (YYLabel *)releaseTimeLabel{
    if (!_releaseTimeLabel) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.textColor = [UIColor customTextGrayBlackColor];
        _releaseTimeLabel = label;
        [self.contentView addSubview:_releaseTimeLabel];
    }
    return _releaseTimeLabel;
}

- (YYLabel *)resultLabel{
    if (!_resultLabel) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.textColor = [UIColor customTextGrayBlackColor];
        _resultLabel = label;
        [self.contentView addSubview:_resultLabel];
    }
    return _resultLabel;
}

- (YYLabel *)numberLabel{
    if (!_numberLabel) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.textColor = [UIColor customTextGrayBlackColor];
        _numberLabel = label;
        [self.contentView addSubview:_numberLabel];
    }
    return _numberLabel;
}

- (YYLabel *)keepWatchPeopleleLable{
    if (!_keepWatchPeopleleLable) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.numberOfLines = 0;
        label.textColor = [UIColor customTextGrayBlackColor];
        _keepWatchPeopleleLable = label;
        [self.contentView addSubview:_keepWatchPeopleleLable];
    }
    return _keepWatchPeopleleLable;
}

- (YYLabel *)keepWatchPlaceLable{
    if (!_keepWatchPlaceLable) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.numberOfLines = 0;
        label.textColor = [UIColor customTextGrayBlackColor];
        _keepWatchPlaceLable = label;
        [self.contentView addSubview:_keepWatchPlaceLable];
    }
    return _keepWatchPlaceLable;
}

- (YYLabel *)keepWatchLineLable{
    if (!_keepWatchLineLable) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.numberOfLines = 0;
        label.textColor = [UIColor customTextGrayBlackColor];
        _keepWatchLineLable = label;
        [self.contentView addSubview:_keepWatchLineLable];
    }
    return _keepWatchLineLable;
}

- (YYLabel *)keepWatchTimeSlotLabel{
    if (!_keepWatchTimeSlotLabel) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.textColor = [UIColor customTextGrayBlackColor];
        _keepWatchTimeSlotLabel = label;
        [self.contentView addSubview:_keepWatchTimeSlotLabel];
    }
    return _keepWatchTimeSlotLabel;
}

- (YYLabel *)keepWatchEquimentAll{
    if (!_keepWatchEquimentAll) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.textColor = [UIColor customTextGrayBlackColor];
        _keepWatchEquimentAll = label;
        [self.contentView addSubview:_keepWatchEquimentAll];
    }
    return _keepWatchEquimentAll;
}

- (YYLabel *)thisTimeHadFinishLabel{
    if (!_thisTimeHadFinishLabel) {
        YYLabel *label = [[YYLabel alloc] init];
        label.font = kContentFont;
        label.textColor = [UIColor customTextGrayBlackColor];
        _thisTimeHadFinishLabel = label;
        [self.contentView addSubview:_thisTimeHadFinishLabel];
    }
    return _thisTimeHadFinishLabel;
}
@end
